<?php 
	session_start();
    require_once("site/include/utils_site.php"); 
    require_once("include/classes/phpmailer/class.phpmailer.php"); 
    require_once("include/classes/phpmailer/class.mail.php"); 
	require_once("utils.inc"); 

	if (isset($_POST['contact'])) {
		
        $nume = $_POST['nume'];
        $email = $_POST['email'];
        $mesaj = $_POST['mesaj'];
        $rezultat = $_POST['rezultat'];
        
		$corp_mesaj = "Contact (prin site) primit de la: $nume\n<br>";
        $corp_mesaj .= "e-mail: $email\n<br>";
		$corp_mesaj .= "Mesajul trimis este:\n\n $mesaj\n<br>";
		
		$catre = "tricasoft@gmail.com, domnulnopcea@gmail.com, domnuprofesor@gmail.com";
		
		$pass = true;
		
		//server validation
		if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
			$_SESSION['contact_error_msg'] = LANG_mail_not_found;
			$pass = false;
		}
		if ($pass)
			if (strlen($nume) == 0) {
				$_SESSION['contact_error_msg'] = LANG_Nume_Missing;
				$pass = false;
			}
		if ($pass)
			if (strlen($mesaj) == 0) {
				$_SESSION['contact_error_msg'] = LANG_Mesaj_Missing;
				$pass = false;
			}
		if ($pass)
			if ($rezultat != $_SESSION['security_key']) {
				$_SESSION['contact_error_msg'] = LANG_Mesaj_Rezultat_Incorect;
				$pass = false;
			}
		//end server validation

		if ($pass) {
            sendEmailContactFromSite("Contact - program softy (prin site) - $tipul", $corp_mesaj);
	        $_SESSION["contact_error_msg"] = LANG_Contact_Trimis;
		}
	}
	
	generate_numbers_and_store_result();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Online Logistics</title>
<link href="./include/css/site_style.css" rel="stylesheet" type="text/css" />
</head>

<body>

<?php 
    renderSiteHeader();
?>

<div id="bodyPan">
  <div id="bodyleftPan">
	<h3>Trica Soft S.R.L.</h3>
	<hr />

		Gh. Lazar, Nr. 7-9, Ap. 18, Sannicolau Mare, <br>Timis, Romania.
		<br />Tel: (0040) 770 909 446, (0040) 722 329 318
		<br />Fax: (0040) 356 008 494
		<br />Email: contact@onlinelogistics.eu
		<br />WWW: www.onlinelogistics.eu
		
  	<p align="center"><img src="images/productBox2.jpg" border="0" height="250"></p>
    <br />
  </div>
  <div id="bodyrightPan">
    <div id="loginPan" class="contact">
		<h2><?php echo LANG_Contactatine; ?></h2>
		<form class="contact" method="post" action="site_contact.php">
			<table border="0">
				<tr>
					<td><?php echo LANG_Nume; ?></td>
					<td><input class="contact" name="nume" type="text" id="email" value="<?php if (isset($_POST['nume'])) echo $_POST['nume']; ?>"/></td>
				</tr>
				<tr>
					<td>Email</td>
					<td><input class="contact" name="email" type="text" id="email" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>"/></td>
				</tr>
				<tr>
					<td><?php echo LANG_Mesaj; ?></td>
					<td><textarea class="forgot" name="mesaj" id="mesaj" cols="27" rows="6"><?php if (isset($_POST['mesaj'])) echo $_POST['mesaj']; ?></textarea></td>
				</tr>
				<tr>
					<td><?php echo $_SESSION['number_x'] . "*" . $_SESSION['number_y']; echo ' = '; ?></td>
					<td valign="top"><input class="cod" name="rezultat" type="text" id="email"/></td>
				</tr>
				<tr>
					<td colspan="2"><input class="contactbutton" name="contact" type="submit" value="Trimite" /></td>
				</tr>
				<?php
					if (isset($_SESSION['contact_error_msg'])) {
						echo '<tr>';
							echo '<td colspan="2" style="color: red">';
								echo ($_SESSION['contact_error_msg']);
								unset($_SESSION['contact_error_msg']);
							echo '</td>';
						echo '</tr>';
					}
				?>
			</table>
		</form>
	</div>
	<div id="loginBottomPan">&nbsp;</div>
  </div>
</div>
<?php render_footer_site(); ?>
</body>
</html>